<?php
    $text3='';
    if(!empty($_POST)){
        $text1=$_POST['txt'];
        $text2=$_POST['txt1'];
        $fh=$_POST['Symbol'];
        switch ($fh){
            case "+":
                $text3=$text1+$text2;
                break;
            case "-":
                $text3=$text1-$text2;
                break;
            case"*":
                $text3=$text1*$text2;
                break;
            case"/":
                if($text1!=0){
                    $text3=$text1/$text2;
                    break;
                }else{
                    echo "除数不为0";
                }
        }
        // echo $text3;
    }
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <form  method="POST">
    <input type="text" name="txt">
    <select name="Symbol" id="">
        <option value="+">+</option>
        <option value="-">-</option>
        <option value="*">*</option>
        <option value="/">/</option>
    </select>
    <input type="text" name="txt1">
    <input type="submit" value="计算">
    <input type="text" name="txt2" value="<?php echo $text3 ?>">
    </form>
</body>
</html>
